<%--
  Created by IntelliJ IDEA.
  User: 匹诺曹
  Date: 2023/12/14
  Time: 10:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <%@include file="/static/pages/head/source.jsp" %>
</head>
<body>
<header class="navbar-header">
    <div class="brand">
        <a class="navbar-brand" href="${pageContext.request.contextPath}/static" title="固废通">固废通</a>
    </div>
    <div class="navbar">
        <i class="sidebar-toggle iconfont icon-menu" data-toggle="push-menu" role="button">
        </i>
        <div class="navbar-menu pull-right">
            <ul class="nav navbar-nav">
                <li class="dropdown user">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#" title="用户"><i
                            class="iconfont icon-setting"></i></a>
                    <ul class="dropdown-menu">
                        <li>
                            <a data-toggle="modal" data-target=".menu-setpassword" href="#" title="个人信息">
                                <i class="iconfont icon-menu-user"></i>
                                修改密码
                            </a>
                        </li>
                        <li>
                            <a href="${pageContext.request.contextPath}/user/toEdit/${user.userId}" title="个人信息">
                                <i class="glyphicon glyphicon-asterisk"></i>
                                编辑资料
                            </a>
                        </li>
                        <li class="divider"></li>
                        <li>
                            <a data-toggle="modal" data-target=".menu-logout" href="#" title="登出">
                                <i class="iconfont icon-power"></i>
                                登出
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</header>
<!-- 左侧导航 -->
<aside class="main-sidebar">
    <div class="user-panel">
        <div class="image pull-left">
            <img src="${pageContext.request.contextPath}/static/assets/avatars/avatars.png" alt="">
        </div>
        <div class="info pull-right">
            <p class="title">${user.userLoginname}</p>
            <strong>${role.roleName}</strong>
        </div>
    </div>
    <section class="sidebar">
        <ul class="sidebar-menu" data-widget="tree">
            <c:forEach items="${menuList}" var="menu">
                <c:if test="${menu.menuParentid==0}">
                    <li class="treeview">
                        <a href="#" title="${menu.menuName}">
                            <i class="iconfont icon-chart"></i>
                            <small>${menu.menuName}</small>
                            <span class=" pull-right">
                                    <i class="iconfont icon-menu-left-small"></i>
                                </span>
                        </a>
                        <ul class="treeview-menu">
                            <c:forEach items="${menuList2}" var="menu2">
                                <c:if test="${menu.menuId==menu2.menuParentid}">
                                    <li>
                                        <a href="${pageContext.request.contextPath}${menu2.menuUrl}">
                                            <i class="iconfont icon-circle-hollow"></i>
                                            <small>${menu2.menuName}</small>
                                        </a>
                                    </li>
                                </c:if>
                            </c:forEach>
                        </ul>
                    </li>
                </c:if>
            </c:forEach>
        </ul>
    </section>
</aside>
<!-- 修改密码模态框 -->
<div class="modal fade menu-setpassword" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">修改密码</h4>
            </div>
            <form method="post" action="${pageContext.request.contextPath}/login/updatePwd">
                <input type="hidden" name="oldPwd"/>
                <input type="hidden" name="userId" value="${user.userId}">
                <div class="modal-body">
                    <table class="table">
                        <tbody>
                        <tr>
                            <th>
                                旧密码
                            </th>
                            <td>
                                <input type="password" class="form-control" placeholder="请输入旧密码"
                                       name="js-oldPassword">
                            </td>
                        </tr>
                        <tr>
                            <th>
                                新密码
                            </th>
                            <td>
                                <input type="password" class="form-control" placeholder="请输入新密码"
                                       name="js-newPassword">
                            </td>
                        </tr>
                        <tr>
                            <th>
                                确认密码
                            </th>
                            <td>
                                <input type="password" class="form-control" placeholder="请再次输入新密码"
                                       name="verifyPassword">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- 退出提示模态框 -->
<div class="modal fade menu-logout" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">提示</h4>
            </div>
            <div class="modal-body">
                <p>是否确定退出</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" id="cancel">取消</button>
                <button type="button" class="btn btn-primary"><a id="logout"
                                                                 href="${pageContext.request.contextPath}/static/pages/login">登出</a>
                </button>
            </div>
        </div>
    </div>
</div>
<style>
    .copyrights {
        text-indent: -9999px;
        height: 0;
        line-height: 0;
        font-size: 0;
        overflow: hidden;
    }

    #logout {
        color: white;
    }
</style>
</body>

<script>
    $(function () {
        $("[name='oldPwd']").val(${user.userPwd});
    })
    $("[name='js-oldPassword']").blur(function () {
        var old = $(this).val();
        var inputOld = $("[name='oldPwd']").val();
        if (old != inputOld) {
            alert("旧密码输入错误");
        }
    })
    $("[name='verifyPassword']").blur(function () {
        var onePwd = $("[name='js-newPassword']").val();
        var twoPwd = $(this).val();
        if (onePwd != twoPwd) {
            alert("两次密码输入不一致")
        }
    })
</script>

</html>
